package com.goldenKey.admin.controller;

import com.goldenKey.common.pojo.result.R;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.goldenKey.common.pojo.po.BookQuantity;
import com.goldenKey.admin.service.IBookQuantityService;

/**
 * @Author: 吃我一钊
 * @Description: 控制层
 * @Date: 2025/02/02
 */
@RestController
@RequestMapping("/bookQuantity")
public class BookQuantityController {

	@Autowired
	private IBookQuantityService bookQuantityService;

	/**
	 * 新增数据
	 * @param bookQuantity
	 * @return
	 */
	@PostMapping("/save")
	public R<Void> save(@RequestBody BookQuantity bookQuantity) {
		bookQuantityService.save(bookQuantity);
		return R.ok();
	}

	/**
	 * 根据id删除
	 * @param bookQuantityId
	 * @return
	 */
	@DeleteMapping("/deleteById/{bookQuantityId}")
	public R<Void> deleteById(@PathVariable("bookQuantityId") Integer bookQuantityId) {
		bookQuantityService.removeById(bookQuantityId);
		return R.ok();
	}

	/**
	 * 根据id修改数据
	 * @param bookQuantity
	 * @return
	 */
	@PutMapping("/updateById")
	public R<Void> updateById(@RequestBody BookQuantity bookQuantity) {
		bookQuantityService.updateById(bookQuantity);
		return R.ok();
	}

	/**
	 * 根据id查询数据
	 * @param bookQuantityId
	 * @return
	 */
	@GetMapping("/getById/{bookQuantityId}")
	public R<BookQuantity> getById(@PathVariable("bookQuantityId") Integer bookQuantityId) {
		BookQuantity bookQuantity = bookQuantityService.getById(bookQuantityId);
		return R.ok(bookQuantity);
	}
	/**
	 * 查询所有数据
	 * @return
	 */
	@GetMapping("/list")
	public R<List<BookQuantity>> list() {
		List<BookQuantity> bookQuantityList = bookQuantityService.list();
		return R.ok(bookQuantityList);
	}

}